package com.DataProcess;

import android.util.Log;

import com.pudu.mydemo.entity.Contant;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by lgq on 2016/10/17.
 */
public class UIDataProcess {
    static String thisLogTag = "UIDataProcess";

    public static void putOrigin(String string) {
        String actionMode = "fail";
        int data = 0;

        Log.i(thisLogTag,"data from UI:" + string);
        try {
            JSONObject jsonObject = new JSONObject(string);
            actionMode = jsonObject.getString("action");
            data = jsonObject.getInt("data");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        switch (actionMode) {
            case Contant.ACTION_SMART_MOVE:
                Robot.mode = Contant.ACTION_SMART_MOVE;
                Robot.isAuto= true;
//                Robot.isEnable = true;
                Log.i(thisLogTag,"debug start ACTION_SMART_MOVE");
                break;
            case Contant.ACTION_THROUGH_MOVE:
                Robot.mode = Contant.ACTION_THROUGH_MOVE;
                Robot.isAuto = true;
                break;
            case Contant.ACTION_GO:
                if(Robot.isInitPosSucceed)
                    Robot.isEnable = true;
                Log.i(thisLogTag,"init test:　click go " + Robot.isEnable);
                break;
            case Contant.ACTION_PAUSE:
                Robot.isEnable = false;
                break;
            case Contant.ACTION_HOME:
                Robot.mode = Contant.ACTION_HOME;
                break;
            case Contant.ANIMATION_FIRST_TIME_COMPLETE:
                Log.i(thisLogTag,"ANIMATION_FIRST_TIME_COMPLETE");
                break;
            default:
        }
        Log.i("isEnable","ui make isEnable "+Robot.isEnable);
    }
}
